// china_map_component.js
var chartDom = document.getElementById('chinaMap');
var myChart = echarts.init(chartDom);
var option;

option = {
    tooltip: {
        trigger: 'item',
        formatter: '{b}<br/>占比: {c}%'
    },
    visualMap: {
        min: 0,
        max: 25,
        left: 'left',
        top: 'bottom',
        text: ['高', '低'], // 文本，默认为数值文本
        calculable: true,
        inRange: {
            color: ['#e0ffff', '#006edd']
        }
    },
    series: [
        {
            name: '调节服务项占比',
            type: 'map',
            mapType: 'china',
            roam: false,
            label: {
                show: true
            },
            data: []
        }
    ]
};

myChart.setOption(option);

function updateMap(data) {
    const seriesData = data.map(item => ({
        name: item.name,
        value: parseFloat(item.value)
    }));
    option.series[0].data = seriesData;
    myChart.setOption(option);
}

export { updateMap };